<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>街道列表页</title>
    <%@include file="../util/common.jsp"%>
    <style>
        form{
            padding: 10px 5px;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>街道列表</h1>
    <div class="row">
        <div class="col-md-12">
            <form id="search-form" class="form-inline" action="${pageContext.request.contextPath}/rent/streets">
                <div class="form-group">
                    <label for="streetName">街道名称：</label>
                    <input type="text" class="form-control" name="streetName" id="streetName" placeholder="" value="${streetName}">
                </div>
                <div class="form-group">
                    <label for="did">区县：</label>
                    <select id="did" name="did" class="form-control">
                        <option value="-1">全部区县</option>
                        <!-- 从Servlet中获取区县集合，进行遍历 -->
                        <c:forEach var="dis" items="${districts}">
                            <option value="${dis.id}" <c:if test="${dis.id eq did}">selected</c:if>>${dis.name}</option>
                        </c:forEach>
                    </select>
                </div>
                <input type="hidden" name="pageNo" id="pageNo">
                <button type="submit" class="btn btn-default"> 搜索 </button>
                <a href="<c:url value="/rent/street">
                            <c:param name="action" value="add" />
                        </c:url>" class="btn btn-info"> 新增街道 </a>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>街道名称</th>
                    <th>所属区县</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${streets}" var="street" varStatus="status">
                    <tr>
                        <!-- 获取集合遍历时的序号 -->
                        <td>${status.count}</td>
                        <td>${street.name}</td>
                        <td>${street.district.name}</td>
                        <td>
                            <a class="btn btn-primary btn-xs"
                               href="<c:url value="/rent/street">
                                        <c:param name="action" value="update" />
                                        <c:param name="id" value="${street.id}"/>
                                    </c:url>">编辑</a>
                            <a class="btn btn-warning btn-xs"
                                    href="<c:url value="/rent/street">
                                            <c:param name="action" value="delete" />
                                            <c:param name="id" value="${street.id}"/>
                                        </c:url>">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <c:import url="/util/pageInfo.jsp">
        <c:param name="pageNo" value="${pageNo}"/>
        <c:param name="pageCount" value="${pageCount}"/>
        <c:param name="totalCount" value="${totalCount}"/>
    </c:import>
</div>

</body>
</html>